Enter a number to find the perimeter of a square with a side length of the value you entered.
Negative values will not be accepted.
by Alex '24
def times_4(side):
invalid = -1
perim = side * 4
while perim == side * 4:
if perim >= 0:
return perim
else:
return invalid
Function Call | Return Value | |||
---|---|---|---|---|
times_4(2) | → | |||
times_4(0) | → | |||
times_4(-50) | → | |||
times_4(-3) | → | |||
times_4(12) | → |
Experiment with this code on Gitpod.io